<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="js/lib/angular.min.js"></script>	
		<link rel="stylesheet" href="css/lib/bootstrap.min.css" />
		<link rel="stylesheet" href="js/themes/default/easyui.css" />
		<script src="js/lib/jquery-1.11.0.js"></script>
		<script src="js/lib/bootstrap.min.js"></script>		
	</head>
	<style>
		body{
			font-size:12px;
		}
		table,
		th,
		td {
			border: 1px solid #ccc;
			border-collapse: collapse;
			padding: 5px;
			vertical-align: middle !important;
		}
		
		table td:nth-child(odd) {
			background-color: #f1f1f1;/*#e2e9ea*/
			
		}
		table td:nth-child(even) {
			
		}
		table tr:nth-child(even) {
			background-color:#ffffff;
		}
		input{
			width:280px;
		}
		span{
			width:20px;color:red;display:inline-block;text-align:center;
		}
		#sho{
			width:300px;
			height:50px;
			background:#d9534f;
			opacity:0.8;
			border-radius:8px;
			color:#fff;
			text-align: center;
			font-size:30px;
			position: absolute;
			top:0px;
			left:550px;
			display:none;
		}
	</style>
	<body ng-app="myApp" ng-controller="customersCtrl">
		<div class="">
			<div id="sho"></div>
			<!--第一个查询-->
		<div style="padding:15px 5px 0px 5px;border:1px solid #ccc;margin-bottom:15px;width:100%">
			<table class="table table-hover" style="width:30%;float:left">				
					<tr>
						<th style="font-size:20px;color:#666" colspan="10">设置用户快捷扫码通道费率</th>
					</tr>
					<tr>
						<td style="width:45px;" class="text-center">序号</td>
						<td class="text-center">通道名称</td>
					
						<td class="text-center">刷卡费率</td>						
						<td class="text-center">提款手续费</td>
						<td class="text-center">额外费用</td>
						<td class="text-center">变更</td>
					</tr>
					<tr ng-repeat="item in items2" ng-if="item.status==1">
						<td class="text-center">{{item.id}}</td>
						<td class="text-center">{{item.name+"【"+item.channelParams+"】"}}</td>
											
						<td  class="text-center"  contenteditable="true">
							<input type="text" ng-model="item.rate" style="width:50px;margin:0 auto;">
						</td>	
						<td class="text-center">
							<input type="text" disabled="true" ng-model="item.withdrawFee" style="width:40px;margin:0 auto;">
						</td>
						<td class="text-center">
							<input type="text" ng-model="item.extraFee" style="width:40px;margin:0 auto;">
						</td>						
						<td class="text-center"><button ng-click="add(item)">修改</button></td>
					<tr>
						<td colspan="10" id="show02" class="text-center" style="display:none;">
						</td>
					</tr>
					<tr>
						<td colspan="10" id="show02" class="text-center" style="color:red;">
							PS:提现手续费为通道成本，额外费用为返还给平台的利润，请谨慎设置添加！
						</td>
					</tr>				
			</table>
			<table class="table table-hover" style="width:30%;float:left">				
					<tr>
						<th style="font-size:20px;color:#666" colspan="10">设置用户还款通道费率</th>
					</tr>
					<tr>
						<td style="width:45px;" class="text-center">序号</td>
						<td class="text-center">通道名称</td>
					
						<td class="text-center">刷卡费率</td>						
						<td class="text-center">提款手续费</td>
						<td class="text-center">额外费用</td>
						<td class="text-center">变更</td>
					</tr>
					<tr ng-repeat="item in items2" ng-if="item.channelTag=='HL_PAY' || item.channelTag=='CREDICTPAY'">
						<td class="text-center">{{item.id}}</td>
						<td class="text-center">{{item.name+"【"+item.channelParams+"】"}}</td>
											
						<td  class="text-center" contenteditable="true">
							<input type="text" ng-model="item.rate" style="width:50px;margin:0 auto;">
						</td>	
						<td class="text-center">
							<input type="text" disabled="true" ng-model="item.withdrawFee" style="width:40px;margin:0 auto;">
						</td>
						<td class="text-center">
							<input type="text" ng-model="item.extraFee" style="width:40px;margin:0 auto;">
						</td>						
						<td class="text-center"><button ng-click="add(item)">修改</button></td>
					</tr>
					<tr>
						<td colspan="10" id="show02" class="text-center" style="display:none;">
						</td>
					</tr>				
			</table>				
		</div>
		</div>
	</body>
	<script>
		var app = angular.module('myApp', []);
		/*自定义过滤器   1*/
				app.filter('modify0',function(){
					return function(input,param){
						if(param == "1"){
							return param = "开"
						}
						if(param == "2"){
							return param = "关"
						}
					}
				});

	        app.controller('customersCtrl', function($scope, $http ){
	        	var brandid = sessionStorage.getItem(key=3); 
				/*$('#f1').val(userid);*/
				/*根据用户编号展示所有平台信息和费率*/
				var data = {
					thirdLevelId:0,
					access_type:0,
					brand_id:brandid	
				};
				console.log(data);
				$http({
					method: 'POST',
					params: data,
					url: window.baseUrl+'user/thirdlevel/rate/query/thirdlevelid'
				}).then(function successCallback(data){
						console.log("请求数据成功...");
						console.log(data.data.result);
						$scope.items2 = data.data.result
				}, function errorCallback(data) {
						console.log("请求数据失败...");
				     	console.log(data)
				});
				/*修改用户刷卡费率*/
				$scope.add = function(item){                   
				    console.log(item);
                    var brandid = sessionStorage.getItem(key=3);
					var id = item.id;
					var rate = item.rate;
					var e_f = item.extraFee;
					console.log(e_f);
                    $http({
                        method: 'POST',
                        params: {
                        	brand_id:brandid,
	                        channel_id:id,
	                        rate:rate,
	                        status:1,
	                        extra_fee:e_f
                        },
                        url: window.baseUrl+'user/brandrate/add'
                    }).then(function successCallback(data){
                        console.log("修改数据成功...");
                        console.log(data.data.result);
                        if(data.data.resp_code == 000000)
                        alert("成功设置【"+item.name+item.channelParams+"】通道刷卡费率为"+item.rate+"手续费"+item.withdrawFee+"元"+"额外费用"+item.extraFee+"元");
						if(data.data.resp_code == 999999)
						alert(data.data.resp_message);	

                    }, function errorCallback(data) {
                        console.log("修改数据失败...");
                        console.log(data)
                    })
                }
			});
	</script>
</html>




